package SI::Person::Salary;

use base qw/MyDB::Object/;



__PACKAGE__->meta->setup(
    table => 'BaseSalary',
    columns =>
    [
        base_sn => { type => 'varchar', length => 16, not_null => 1 },
        year => { type => 'int', not_null => 1 },
        begin_time => {type=>'datetime', not_null=>1},
        end_time => {type=>'datetime', not_null=>1},
        months => {type=>'int',not_null=>1},
        base_salary => {type=>'decimal'},
        salary => {type=>'decimal'},
    ],
    allow_inline_column_values => 1,
    primary_key_columns => [ 'base_sn', 'year' ],
);

sub init_tab {
    my $self = shift;
    my $stmt = 'CREATE TABLE IF NOT EXISTS BaseSalary (
                base_sn VARCHAR(16) NOT NULL,       /* 人员序列号 */
                year INT NOT NULL,                  /* 年度      */
                begin_time DATE NOT NULL,           /* 起始日期   */
                end_time DATE NOT NULL,             /* 终止日期   */
                months INT NOT NULL,                /* 缴费月数   */
                base_salary DECIMAL(10,0) NOT NULL, /* 缴费基数   */
                salary DECIMAL(10,0) NOT NULL       /* 申报收入   */
                );';
    my $db = $self->init_db;
    my $dbh = $db->dbh or die $db->error;
    $db->do_transaction(sub {$dbh->do($stmt)})
        or die $db->error;
    return 1;

}



1;
